import { App_Interface } from "../app_interface";
import { Adapter } from "../../renderer/adapter";
import { Tile } from "../../tile/tile";
import { BitMath } from "../../math/math";

export namespace GridElement
{
    export class Image implements App_Interface.IGridElement
    {
        get IsGroup():boolean 
        {
            return false;
        }
        get TileXGlobal(): number
        {
            if (this.Parent == null)
                return this.TileRectLocal.x;
            else
                return this.TileRectLocal.x + this.Parent.TileXGlobal;
        }
        get TileYGlobal(): number
        {
            if (this.Parent == null)
                return this.TileRectLocal.y;
            else
                return this.TileRectLocal.y + this.Parent.TileYGlobal;
        }

        TileRectLocal: BitMath.Rect =
            new BitMath.Rect(0, 0, 1, 1);


        image: Tile.IDrawElement_WithSize | null = null;
        multiColor?: BitMath.Color8Bit_RGB;

        private static _RenderRect: BitMath.Rect = new BitMath.Rect(0, 0, 8, 8);
        // OnDraw(render: Adapter.IRenderAdapter): void
        // {
        //     if (this.image == null)
        //         return;


        //     Image._RenderRect.x = this.TileXGlobal * 8;
        //     Image._RenderRect.y = this.TileYGlobal * 8;
        //     Image._RenderRect.w = this.TileRectLocal.w * 8;
        //     Image._RenderRect.h = this.TileRectLocal.h * 8;
        //     this.image.DrawScale(render, Image._RenderRect, this.multiColor);
        // }
        Parent: App_Interface.IGridElementGroup | null = null;
        SetParent(parent: App_Interface.IGridElementGroup): void
        {
            this.Parent = parent;
        }

    }

}